package com.ttctracker.map;

import java.util.ArrayList;
import java.util.HashMap;

import com.ttctracker.R;
import com.ttctracker.classes.StopItem;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.TextView;

public class ViewStopPredictions extends Activity{
	
	private ListView stopPredictionsListView;
	//private ArrayList<StopItem> predictionsStopItems;
	private HashMap<String, StopItem>stopItemsMap;
	private TextView predictionStopTitle;
	private StopItem[] predictionStopItems;
	private String[] predictionStopDirs;
	private StopPredictionArrayAdapter stopArrayAdapter;
	private Intent intent;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.view_list_stop_predictions);
		predictionStopTitle=(TextView)findViewById(R.id.view_stop_predictions_title_txt);
		stopPredictionsListView=(ListView)findViewById(R.id.list_stop_predictions);
		
		intent=getIntent();
		String stopTitle=intent.getStringExtra("stopTitle");
		stopItemsMap=(HashMap<String, StopItem>) intent.getSerializableExtra("stopItems");
		
		predictionStopTitle.setText(stopTitle);
		
		int size=stopItemsMap.size();
		predictionStopItems=stopItemsMap.values().toArray(new StopItem[size]);
		predictionStopDirs=stopItemsMap.keySet().toArray(new String[size]);
		
		
		stopArrayAdapter=new StopPredictionArrayAdapter(this, R.layout.row_stop_predictions, predictionStopItems, predictionStopDirs);
		stopPredictionsListView.setAdapter(stopArrayAdapter);
	}
}
